package myMap

import "fmt"

func init()  {
	scoreMap :=make(map[string]int,8)
	scoreMap["张三"]=90
	scoreMap["小明"]=100
	fmt.Println(scoreMap)
	fmt.Println(scoreMap["小明"])
	fmt.Printf("type of a:%T\n",scoreMap)
	userInfo:=map[string]string{
		"username":"pprof.cn",
		"password":"123456",
	}
	fmt.Println(userInfo)

	v,ok:=scoreMap["张三"]
	if ok {
		fmt.Println(v)
	}
	delete(scoreMap,"小明")
	for k1,v1 := range scoreMap{
		fmt.Println(k1,v1)
	}
	//map类型的切片
	var mapSlice = make([]map[string]string,3)
	for index,value :=range mapSlice{
		fmt.Println(index,value)
	}
	mapSlice[0]=make(map[string]string,10)
	mapSlice[0]["name"]="王五"
	mapSlice[0]["password"]="12345"
	mapSlice[0]["address"]="红旗大街"
	for index1,value1 := range mapSlice{
		fmt.Println(index1,value1)
	}

	var sliceMap = make(map[string][]string,3)
	fmt.Println(sliceMap)
	key:="china"
	value2,ok2:=sliceMap[key]
	if !ok2{
		value2=make([]string,0,2)
	}
	value2 = append(value2,"Beijing","Shanghai")
	sliceMap[key] = value2
	fmt.Println(sliceMap)

	fmt.Println("------------------------")
}